﻿
using CSharpLibs.Annotations;

namespace System
{
	[Builtin]
	public class Tuple<T0, T1> : Object
	{
		private readonly T0 m_item1;
		private readonly T1 m_item2;

		public Tuple(T0 item1, T1 item2)
		{
			this.m_item1 = item1;
			this.m_item2 = item2;
		}

		public T0 Item1
		{ get { return this.m_item1; } }

		public T1 Item2
		{ get { return this.m_item2; } }

		public override bool Equals(object obj)
		{
			if(!(obj is Tuple<T0,T1>))
				return false;
			else
			{
				Tuple<T0, T1> ot = (Tuple<T0, T1>)obj;

				bool m1 = Collections.Generic.EqualityComparer<T0>.DefaultEquals(this.m_item1, ot.m_item1);
				bool m2 = Collections.Generic.EqualityComparer<T1>.DefaultEquals(this.m_item2, ot.m_item2);
				
				return (m1 & m2);
			}
		}

		public override int GetHashCode()
		{
			int h1 = Collections.Generic.EqualityComparer<T0>.DefaultGetHashCode(this.m_item1);
			int h2 = Collections.Generic.EqualityComparer<T1>.DefaultGetHashCode(this.m_item2);
			return (((h1 << 5) + h1) ^ h2); ;
		}
	}
}

